<?php

class My_Controller_Plugin_LoadCss extends Zend_Controller_Plugin_Abstract
{
    protected $viewInstance;
    
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $module = $request->getModuleName();
        if (is_null($module)) $module = 'default';
        $this->viewInstance = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
        switch ($module)
        {
            case 'default':
                $this->loadDefaultCss();
                break;
            case 'admin':
                $this->loadDefaultCss();
                $this->loadAdminCss();
                break;
            case 'developer':
                $this->loadDefaultCss();
                $this->loadDeveloperCss();
                break;
            default:
                $this->loadDefaultCss();
                break;
        }
    }
    
    protected function loadDefaultCss()
    {
        $this->viewInstance = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
        
        // Main styles
        $this->viewInstance->headLink()->appendStylesheet('/css/global.css');
        $this->viewInstance->headLink()->appendStylesheet('/css/jquery/smoothness/jquery-ui-1.8.17.custom.css');
        $this->viewInstance->headLink()->appendStylesheet('/js/library/jquery/plugin/datepicker/css/datepicker.css');
        
        $this->viewInstance->headLink()->appendStylesheet('/js/library/my/desktop/css/table.css');
        
        // Javascripts files
        $this->viewInstance->headScript()->appendFile('/js/library/jquery/jquery-1.7.1.min.js');
        $this->viewInstance->headScript()->appendFile('/js/library/jquery/jquery-ui-1.8.17.custom.min.js');
        $this->viewInstance->headScript()->appendFile('/js/library/my/tricks.js');
        $this->viewInstance->headScript()->appendFile('/js/library/underscore/underscore.js');
        $this->viewInstance->headScript()->appendFile('/js/library/jquery/plugin/datepicker/js/datepicker.js');
        
        $this->viewInstance->headScript()->appendFile('/js/library/my/widget/table.js');
        
    }
    
    protected function loadAdminCss()
    {
        
    }
    
    protected function loadDeveloperCss()
    {
        
    }
    
}